package main

import "fmt"

type student struct {
	userName string
	password string
	age      int
}

// 学习结构体初始化赋值的几种方式 结构体和数组一样 怎么写都会默认初始化内存
func main() {
	student1 := student{userName: "张三", password: "112"}

	var student2 student
	student2 = student{}
	student2.userName = "王五"
	student2.password = "1234"
	student2.age = 18

	var student3 student
	// student3 = &student{} //  cannot use &student literal (type *student) as type student in assignment
	student3 = *&student{age: 99, userName: "李四"} // 返回的是指针 混合字面量语法

	var student4 student = *new(student) // 和student3的&用法是一样的
	student4.password = "123"

	fmt.Printf("student1: %v\t, student2: %v, student3: %v, student4: %v \n", student1, student2, student3, student4)

}
